#include "thread.h"
int makedir(int netfd,sharInfo_t *sharInfo,MYSQL * mysql){

    train_t recMsg;
    recv(netfd, &recMsg.length, sizeof(recMsg.length),MSG_WAITALL);
    recv(netfd, recMsg.buf, recMsg.length,MSG_WAITALL);
    remove_trailing_invisible_chars(recMsg.buf);
    printf("recMsg.buf = %s\n",recMsg.buf);

    char sql[1024];
    char sql1[1024];
    bzero(&sql,sizeof(sql));
    train_t train;
    // 写入目录ID
    get_pwd(sharInfo,mysql,sql1);
    sprintf(sql1,"%s%s/",sql1,recMsg.buf);

    int parID=sharInfo->parentID;
    //  sprintf(sql,"insert into df_mes (parID) values ('dirID')='%d';",sharInfo->rootID);
    if(parID==-1){
        parID=sharInfo->rootID;
        
    }

    sprintf(sql,"insert into df_mes(fileName,path,user,parID,md5,tomb) values ('%s','%s','%s','%d',0,0);",recMsg.buf,sql1,sharInfo->user,parID); 
    printf("sql = %s\n",sql);


    int ret=mysql_query(mysql,sql);
    if(ret != 0){
        fprintf(stderr,"mysql_query:%s\n", mysql_error(mysql));
        ret =-1;
        send(netfd,&train.length,sizeof(int),MSG_NOSIGNAL);
        return -1;
    }
    train.length = 0;
    send(netfd,&train.length,sizeof(int),MSG_NOSIGNAL);
    return 0;
}
